package controller;

import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;
import util.FxmlUtil;

import java.io.IOException;
import java.util.Objects;

public class SelectAccController {
    public Button detail;

    public void balanceAction() throws IOException {
        AnchorPane pane = FXMLLoader.load(Objects.requireNonNull(Thread.currentThread().getContextClassLoader().getResource("fxml/balance.fxml")));
        Scene scene = new Scene(pane);
        FxmlUtil.SCENE.put("balance", scene);

        Stage stage = (Stage) this.detail.getScene().getWindow();
        stage.setScene(scene);
        stage.setTitle("ATM - 查看余额");
    }

    public void detailAction() throws IOException {
        AnchorPane pane = FXMLLoader.load(Objects.requireNonNull(Thread.currentThread().getContextClassLoader().getResource("fxml/detail.fxml")));
        Scene scene = new Scene(pane);
        FxmlUtil.SCENE.put("detail", scene);

        Stage stage = (Stage) this.detail.getScene().getWindow();
        stage.setScene(scene);
        stage.setTitle("ATM - 查看明细");
    }

    public void logoutAction() {
        this.detail.getScene().getWindow().hide();
    }
}
